home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS22.ADF
/
BasicSorts
/
BinarySearch.DOC
< prev
next >
Wrap
Text File
|
1987-06-30
|
1KB
|
31 lines
This is the fastest algorithm that I know of for searching through
a sorted list for a certain string. If anyone would like to know more about
why it works, just drop me a line to the address listed at the end of this
document file.
To search for a string just call the BinarySearch subprogram like this:
Call BinarySearch ( Upper%, M$(), T$, P% )
where Upper% is the upper limit of the array, M$() is the array to be
searched through, T$ is the string to be searched for in M$(). P% is
returned 0 by the sub if T$ is not in M$(1..Upper%). P% is returned greater
than zero if M$(P%) = T$. Then you have the index of the first occurance of
T$ in M$(1..Upper%).
NOTE :-
Upper% : can be a number or an integer variable
M$() : must be a variable name of a string array
T$ : must be a variable name of a string
P% : must be a variable name of an integer
For more information just write me at:
Gregory A. Kendall
ATN/ Brendallson Software
522 Neese Road
Woodstock, GA 30188
Auf Wiedersehen!